﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SearchData
{
    public partial class Data : Form
    {
        private bool m_Cancel = false;

        public bool Cancel
        {
            get { return m_Cancel; }
        }

        public Data()
        {
            InitializeComponent();
        }

        private void ProgressBar_FormClosing(object sender, FormClosingEventArgs e)
        {
            
        }
        private void ArrangeGrid()
        {
            grdData.Width = this.Width;
            grdData.Height = this.Height;
            int colCounts = grdData.Columns.Count;
            for (int i = 0; i < colCounts; i++)
            {
                grdData.Columns[i].Width = (this.Width - 55) / colCounts;
            }
        }
        private void ProgressBar_Load(object sender, EventArgs e)
        {
            try
            {
                ArrangeGrid();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void FillGrid(DataSet ds)
        {
            try
            {
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    grdData.DataSource = ds.Tables[0];
                }
                else
                {
                    MessageBox.Show("No Record Exists for the selected table.");
                    this.Close();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void Data_Resize(object sender, EventArgs e)
        {
            ArrangeGrid();
        }
    }
}
